<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>试用区-商品编辑</title>
	<link rel="stylesheet" href="<%=path%>/css/bootstrap/3.3.5/css/bootstrap.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cropper.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cz.css" />
	
	<script src="<%=path%>/css/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script src="<%=path%>/js/jquery-1.11.0.min.js"></script>
	<script src="<%=path%>/js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<script src="<%=path%>/js/plugins/layer/layer.js"></script>	
	<script src="<%=path%>/js/common.js"></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/ajaxfileupload.js"></script>
<body class="gray-bg">
<jsp:include page="/views/commons/header.jsp"></jsp:include>
<div class="container page-single">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">商品编辑</h3>
			</div>
			<div class="panel-body event-create">

				<form class="form-horizontal" id="goods_form" action="javascript:insertGoods()">
					<input type="hidden" name="goodsId" value="${goods.goodsId}">
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							商品名称 <em>*</em>
						</label>
						<div class="col-sm-10 ">
							<input class="form-control event-create-form-control-block" maxlength="8" minlength="1" 
							name="goodsName" placeholder="商品名称" type="text" value="${goods.goodsName}">
						</div>
					</div>
					
					<d:radio describe="商品分类" tableColumn="goods_type" fieldName="goodsType" value="${goods.goodsType}"></d:radio>
					
					<d:radio describe="商品状态" tableColumn="goods_status" fieldName="goodsStatus" value="${goods.goodsStatus}"></d:radio>
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							商品描述 <em>*</em>
						</label>
						<div class="col-sm-10">
							<input class="form-control event-create-form-control-block" maxlength="20" minlength="1" 
							name="goodsDetail" placeholder="商品描述" type="text" value="${goods.goodsDetail}">
						</div>
					</div>
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							虚构数量 <em>*</em>
						</label>
						<div class="col-sm-10">
							<input class="form-control event-create-form-control-block" maxlength="8" minlength="1" 
							name="unrealNum" placeholder="虚构数量 " type="text" value="${goods.unrealNum}">
						</div>
					</div>
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							商品属性 <em>*</em>
						</label>
						<div class="col-sm-10">
							<textarea name="goodsProperties" rows="3" cols="93">${goods.goodsProperties}</textarea>
						</div>
					</div>
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							商品原价<em>*</em>
						</label>
						<div class="col-sm-5">
							<input class="form-control event-create-form-control-block" maxlength="15" minlength="1" 
							name="goodsPrice" placeholder="商品原价" type="text" value="${goods.goodsPrice}">
						</div>
						<label  class="col-sm-1 control-label">
							商品运费 <em>*</em>
						</label>
						<div class="col-sm-5">
							<input class="form-control event-create-form-control-block" maxlength="15" minlength="1" 
							name="deliveryFee" placeholder="商品运费" type="text" value="${goods.deliveryFee}">
						</div>
					</div>
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							偏远地区加收邮费<em>*</em>
						</label>
						<div class="col-sm-5">
							<input class="form-control event-create-form-control-block" maxlength="15" minlength="0" 
							name="exDeliveryFee" placeholder="偏远地区加收邮费" type="text" value="${goods.exDeliveryFee}">
						</div>
						<label  class="col-sm-1 control-label">
							要加收邮费的省份 <em>*</em>
						</label>
						<div class="col-sm-5">
							<input class="form-control event-create-form-control-block" maxlength="100" minlength="0" 
							name="remoteArea" placeholder="要加收邮费的省份（多个用英文,分隔）" type="text" value="${goods.remoteArea}">
						</div>
					</div>
					
					<div class="form-group">
						<label for="aa" class="col-sm-1 control-label">上传商品小图(200X200) <em>*</em></label>
						<div class="col-sm-5">
							<div class="img-container">
								<img id="goods_small_img_img" src="<%=path %>/uncheck/pictures/servlet?id=${goods.goodsSmallImg}" width="200" height="200" alt="Picture">
							</div>
							
							<label class="btn btn-primary" for="goods_small_img_file" title="上传图片">
								<input type="file" class="hide" id="goods_small_img_file" name="file" accept="image/*" 
								onchange="javascript:uploadImage('goods_small_img_img','goods_small_img_file','goods_small_img',2)">上传图片
							</label>
							<input type="hidden" id="goods_small_img" name="goodsSmallImg" value="${goods.goodsSmallImg}">
						</div>
						<label for="goods_big_img" class="col-sm-1 control-label">上传商品大图(300X200) <em>*</em></label>
						<div class="col-sm-5" >
							<div class="img-container">
								<img id="goods_big_img_img" src="<%=path %>/uncheck/pictures/servlet?id=${goods.goodsBigImg}" width="300" height="200" alt="Picture">
							</div>
							<label class="btn btn-primary" for="goods_big_img_file" title="上传图片">
								<input type="file" class="hide" id="goods_big_img_file" name="file" accept="image/*" 
								onchange="javascript:uploadImage('goods_big_img_img','goods_big_img_file','goods_big_img',2)">上传图片
							</label>
							<input type="hidden" id="goods_big_img" name="goodsBigImg" value="${goods.goodsBigImg}">
						</div>
					</div>
					
					
					<div class="form-group">
						<label  class="col-sm-1 control-label">
							商品生产商
						</label>
						<div class="col-sm-10">
							<input class="form-control event-create-form-control-block" maxlength="400" 
							name="goodsProducers" placeholder="商品生产商 " type="text" value="${goods.goodsProducers}">
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-sm-1 control-label">图文介绍<em>*</em></label>
						<div class="col-sm-10">
							<textarea name="goodsIntroduce" style="width:680px;height:400px;visibility:hidden;">
							<fns:encodes value="${goods.goodsIntroduce}" type="4"/>
							</textarea>
						</div>
					</div>
					
					<div class="form-group">
						<div class="col-sm-offset-1 col-sm-10">
							<button type="submit" class="btn btn-primary">提交商品信息</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<jsp:include page="/views/commons/footer.jsp"></jsp:include>

<link rel="stylesheet" href="<%=path %>/js/plugins/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="<%=path %>/js/plugins/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="<%=path %>/js/plugins/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="goodsIntroduce"]', {
				allowFileManager: false,
				allowUpload : true,
				uploadJson:"<%=path %>/uncheck/pictures/upload/json",
				items : ['fontname', 'fontsize', '|',
				         'bold','italic', 'underline', 'forecolor','hilitecolor','link','|',
				         'justifyleft', 'justifycenter', 'justifyright','justifyfull','clearhtml', 'quickformat','|',
				         'image', 'table','emoticons','baidumap', '|', 'about'
				 ]
			});
		});
		$("#data_news_time .input-daterange").datepicker({
			keyboardNavigation: !1,
			forceParse: !1,
			autoclose: !0
		})
	})
	function insertGoods(){
		$("#goods_confirm_btn").addClass("disabled").attr("disabled","disabled").val("提交中");
		$.ajax({
			url : path + "/admin/goods/update",
			type : "post",
			dataType : "json",
			data : $("#goods_form").serialize(),
			success : function(data)
			{
				if(data.result){
					layer.msg("发布成功",{icon: 1});
					window.location.href=path + "/views/admin/admin_center.jsp";
				}else{
					layer.msg(data.message,{icon: 2});
					$("#goods_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
				$("#goods_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
			}
		});
	}
	</script>
</body>
</html>